#include "remindedit.h"
#include "ui_remindedit.h"
#include "mycalendarwidget.h"
#include "QDate"
#include "QToolButton"
RemindEdit::RemindEdit(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::RemindEdit)
{
    ui->setupUi(this);
    ui->dateEdit->setCalendarPopup(true);
    ui->dateEdit->setCalendarWidget(new MyCalendarWidget);
    QToolButton *prevBtn = ui->dateEdit->findChild<QToolButton*>(QLatin1String("qt_calendar_prevmonth"));
    QToolButton *bextBtn = ui->dateEdit->findChild<QToolButton*>(QLatin1String("qt_calendar_nextmonth"));
    prevBtn->setFixedSize(50,50);
    bextBtn->setFixedSize(50,50);
    prevBtn->setIcon(QIcon(":/img/res/img/forward_left.png"));
    prevBtn->setIconSize(QSize(50,50));
    bextBtn->setIcon(QIcon(":/img/res/img/forward_right.png"));
    bextBtn->setIconSize(QSize(50,50));

}
void RemindEdit::update(Remind remind){

    ui->dateEdit->setDate(remind.date);
    ui->amount->setText(QString::number(remind.amount));
    ui->name->setText(remind.name);
    ui->image->showURLImage(remind.pic);
    connect(ui->confirm,&QToolButton::clicked,[=](){

        this->confirm(ui->amount->text().toLong(),ui->dateEdit->date());
        this->close();
    });
    connect(ui->cancel,&QToolButton::clicked,[=](){
        this->close();
    });
}
RemindEdit::~RemindEdit()
{
    delete ui;
}
